home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.2 / AmigaGuide / AG_V34 / Docs / AmigaGuide.txt < prev   
Encoding:
Text File  |  1992-12-30  |  35.6 KB  |  1,249 lines

  1.  
  2.    ************************************************************************
  3.    *                                                                      *
  4.    *                            COPYRIGHTS                                *
  5.    *                                                                      *
  6.    *               UNLESS OTHERWISE NOTED, ALL FILES ARE                  *
  7.    *                                                                      *
  8.    *  Copyright (c) 1985-1992 Commodore-Amiga, Inc.  All Rights Reserved  *
  9.    *                                                                      *
  10.    ************************************************************************
  11.  
  12.  
  13.    ************************************************************************
  14.    *                                                                      *
  15.    *                    COPYRIGHTED DEVELOPER MATERIALS                   *
  16.    *                                                                      *
  17.    ************************************************************************
  18.  
  19.    THIS SOFTWARE AND INFORMATION IS COPYRIGHTED.
  20.  
  21.    THIS SOFTWARE AND INFORMATION MAY NOT BE REDISTRIBUTED, DISCLOSED,
  22.    OR DUPLICATED, IN WHOLE OR IN PART, IN ANY MANNER OTHER THAN AS
  23.    SPECIFIED IN A SIGNED AGREEMENT WITH COMMODORE.
  24.  
  25.    ************************************************************************
  26.    *                                                                      *
  27.    *                            DISCLAIMER                                *
  28.    *                                                                      *
  29.    *   THIS SOFTWARE AND INFORMATION IS PROVIDED "AS IS".                 *
  30.    *   NO REPRESENTATIONS OR WARRANTIES ARE MADE WITH RESPECT TO THE      *
  31.    *   ACCURACY, RELIABILITY, PERFORMANCE, CURRENTNESS, OR OPERATION      *
  32.    *   OF THIS SOFTWARE AND INFORMATION, AND ALL USE IS AT YOUR OWN RISK. *
  33.    *   NEITHER COMMODORE NOR THE AUTHORS ASSUME ANY RESPONSIBILITY OR     *
  34.    *   LIABILITY WHATSOEVER WITH RESPECT TO YOUR USE OF THIS SOFTWARE     *
  35.    *   AND INFORMATION.                                                   *
  36.    *                                                                      *
  37.    ************************************************************************
  38.  
  39.  
  40.  
  41.                             AmigaGuide TM
  42.                            David N. Junod
  43.  
  44.  
  45.                             INTRODUCTION
  46.  
  47.  
  48. The standard Amiga keyboard sports a HELP key, yet there has been no
  49. system provided support for this key.  Now, there is AmigaGuide,
  50. which provides a standard method of displaying help and other on-line
  51. documentation to the user.
  52.  
  53.  
  54.  
  55. Capabilities
  56.  
  57. AmigaGuide uses an Intuition window that contains a scroll bar,
  58. buttons and pull-down menus, to display plain ASCII text files or
  59. AmigaGuide databases.
  60.  
  61. An AmigaGuide database is a set of related documents contained in one
  62. file.  Each document may contain references to other documents, using
  63. what is called a link.  A document may contain any number of links,
  64. pointing to any number of other documents.  When the user selects a
  65. link, the document that the link points to will be displayed.  The
  66. user may then use the links to read through the database, following
  67. whatever path they may choose.  The technical term for AmigaGuide's
  68. abilities, is hypertext.
  69.  
  70. The user may at any time print a document or a portion of the
  71. document.  They may also send portions of a document to the
  72. clipboard, for use in other applications.
  73.  
  74. Using ARexx, the user may write scripts, or an application could
  75. provide scripts, to control AmigaGuide.
  76.  
  77. Cross-reference tables can be loaded that specify where a keyword, or
  78. phrase is defined.  The user can then use AmigaGuide's Find Document
  79. facility to quickly display a document based on keyword, without
  80. having to know the name of the database that it is located in.
  81.  
  82. AmigaGuide provides a unique feature to hypertext systems, called
  83. Dynamic Nodes.  A Dynamic Node is a hypertext or plain text document
  84. that is generated in real-time as opposed to coming from a static
  85. file.  An application that generates Dynamic Nodes is called a
  86. Dynamic Node Host.
  87.  
  88.  
  89.  
  90. Interfacing
  91.  
  92. AmigaGuide databases are accessed in three different ways:
  93.  
  94.  
  95.   o  Databases can be browsed directly from the Workbench or Shell
  96.      using a utility named AmigaGuide, a hypertext replacement for
  97.      More.
  98.  
  99.   o  AmigaGuide support can be added to an existing application, that
  100.      supports ARexx, by using AmigaGuide's ARexx function host
  101.      capabilities.
  102.  
  103.   o  Applications can use the functions of AmigaGuide to provide help
  104.      on gadgets, menus and windows.  For example, the user could
  105.      position the pointer over any gadget or menu item, press help,
  106.      and the appropriate document would be displayed in the
  107.      AmigaGuide window.  The application could also have AmigaGuide
  108.      display a pertinent portion of the current project.
  109.  
  110.  
  111.  
  112. Other Uses
  113.  
  114. In addition to help or on-line documentation, AmigaGuide has other
  115. possible uses.  For example,
  116.  
  117.  
  118.   Tutorials
  119.   An application that has an ARexx port and supports AmigaGuide could
  120.   set up a help system that not only provides help, but could also give
  121.   examples. The user could read about a feature, then click on the
  122.   EXAMPLE button, which would run an ARexx script that would give an
  123.   example of use.  For instances, to show Pattern Fill, the script
  124.   could draw a circle, select a pattern, and then fill the circle.
  125.  
  126.  
  127.   Computer Aided Instruction
  128.   The student could read about different topics, following links.  A
  129.   multiple choice quiz could be set up at the end where the questions
  130.   and answers run ARexx scripts to accumulate the score.
  131.  
  132.  
  133.   Program by Query
  134.   Many programmers develop using a Cut & Paste technique.  They
  135.   clip modules from the various applications or utilities that they
  136.   have written, and paste them together to build new applications.
  137.   A database could be set up of all these different code fragments
  138.   (such as loading and saving ILBM's, clipboard access, playing sounds,
  139.   etc.), you could step through, answering questions, while the sections
  140.   that you need are being appended to a new source file.
  141.  
  142.  
  143.  
  144.                USING AmigaGuide FROM WORKBENCH OR CLI
  145.  
  146.  
  147. A number of utilities are provided to access AmigaGuide databases
  148. from the Workbench or Shell.  These utilities are:
  149.  
  150.  
  151.   AmigaGuide
  152.   This tool is much like the system utility, More, but is also capable of
  153.   interpreting AmigaGuide databases.
  154.  
  155.   LoadXRef
  156.   Used to load a cross-reference from disk into memory.  Multiple
  157.   files can be loaded.
  158.  
  159.   ExpungeXRef
  160.   Used to clear the cross-reference table from memory.
  161.  
  162.  
  163. AmigaGuide
  164.  
  165. The AmigaGuide utility is used for browsing through AmigaGuide
  166. databases. It can be run from the Workbench or the Shell.
  167.  
  168. To use it from Workbench, set the default tool of an AmigaGuide
  169. database's icon to AmigaGuide.  Currently, the AmigaGuide utility
  170. doesn't recognize any tool type parameters.
  171.  
  172. From the Shell, AmigaGuide uses the following command template.
  173.  
  174.  
  175.   DataBase,Document/K,Line/N,PubScreen/K,PortName/K:
  176.  
  177.  
  178. The following are descriptions of the arguments.
  179.  
  180.  
  181.   DataBase
  182.   The name of the AmigaGuide database to display.
  183.  
  184.   AmigaGuide will look in the current directory for the database.  If the
  185.   database isn't found, then AmigaGuide will search through its path for
  186.   the database.  To set the path, see the Path paragraph in the USER
  187.   PREFERENCES section.
  188.  
  189.   Document
  190.   The document within the database to display.  AmigaGuide will use
  191.   the cross-reference table to automatically supply the DataBase and
  192.   Line parameters.
  193.  
  194.   Line
  195.   The line of the document to start displaying from.
  196.  
  197.   PubScreen
  198.   The public screen to open on.  Remember that public screen names are
  199.   case sensitive.
  200.  
  201.   PortName
  202.   The name to assign to the ARexx port for this occurence of AmigaGuide.
  203.  
  204.  
  205. LoadXRef
  206.  
  207. The LoadXRef utility can be used from Workbench or the Shell to load
  208. cross-reference files from disk into memory.  Multiple cross-
  209. reference files may be loaded at a time.
  210.  
  211. From Workbench, just set the default tool of a cross-reference file's
  212. project icon to LoadXRef.  This tool doesn't support any tool type
  213. parameters.
  214.  
  215. From the Shell, just specify the name of the cross-reference file to
  216. load.  LoadXRef will look in the current directory for the file.  If
  217. the file isn't found, then LoadXRef will search through the users
  218. preference path for the file.
  219.  
  220.  
  221. ExpungeXRef
  222.  
  223. The ExpungeXRef utility is used to remove all entries from the cross-
  224. reference table in memory.
  225.  
  226.  
  227.  
  228.                           USER PREFERENCES
  229.  
  230.  
  231. AmigaGuide allows a number of items to be tailored to the users'
  232. preference.  These preference items are stored in environment variables.
  233. The AmigaDOS command SetEnv can be used to set any of these variables.
  234.  
  235. In order to set any of the following environment variables, an
  236. ENV:AmigaGuide directory must be made.
  237.  
  238.   makedir ENV:AmigaGuide
  239.  
  240. A Preference Editor that sets the AmigaGuide preferences would write
  241. in the ENV:AmigaGuide directory when "Use is selected, and write in
  242. the ENVARC:AmigaGuide directory when "Save" is selected.
  243.  
  244. Following is a list of the variable names, and what they control.
  245.  
  246.  
  247. Path
  248.  
  249. This variable contains the list of directory names that AmigaGuide will
  250. search through when it attempts to open a database.  The directory names
  251. are separated by a space.
  252.  
  253.   For example:
  254.  
  255.     SetEnv AmigaGuide/Path "Workbench:Autodocs Workbench:Includes"
  256.  
  257.  
  258. Text
  259.  
  260. Used to specify the graphical style that the links are presented in.
  261. The possible styles are:
  262.  
  263.     BUTTON    Draw a raised border around the text (default).
  264.     UNDERLINE    Underline the text.
  265.     BOLD    Bold the text.
  266.     ITALIC    Italicize the text.
  267.  
  268.   For example:
  269.  
  270.     SetEnv AmigaGuide/Text BUTTON
  271.  
  272.  
  273. Pens
  274.  
  275. This variable provides the user with the ability to specify the
  276. colors to use for the various renderings that AmigaGuide performs.
  277.  
  278.     SetEnv AmigaGuide/Pens <abcdefgh>
  279.  
  280.   Where:
  281.  
  282.     a = Background pen
  283.     b = Button text pen
  284.     c = Button background pen
  285.     d = Highlighted button text pen
  286.     e = Highlighted button background pen
  287.     f = Outline pen
  288.     g = Highlight outline pen
  289.     h = Text on background pen
  290.  
  291.   For example:
  292.  
  293.     SetEnv AmigaGuide/Pens 21213001
  294.     SetEnv AmigaGuide/Text BOLD
  295.  
  296.  
  297. Internally, AmigaGuide subtracts '0' from the pen number, so values
  298. can range from 0 to 207.
  299.  
  300.  
  301.                    AUTHORING AmigaGuide DOCUMENTS
  302.  
  303.  
  304. Authoring an AmigaGuide database, or any hypertext database for that
  305. matter, is a difficult task.  It takes a lot of insight into the
  306. subject matter and how the pieces relate to each other.  A database
  307. must consist of documents that relate to each, documents must be
  308. broken up into manageable chunks, and links must be carefully thought
  309. out.  A document should consist of information dealing with one
  310. topic. Each document should contain links to other related documents.
  311.  
  312. An AmigaGuide database is ASCII text with embedded commands that tell
  313. AmigaGuide how to interpret the database.  A database should consist
  314. of a main table of contents and a number of related documents.
  315.  
  316.  
  317. Label Commands
  318.  
  319. These are commands that can be used within a database.  Commands must
  320. start in the very first column of a line.  If a line begins with an @
  321. sign, then it is interpreted as a command.
  322.  
  323.  
  324.   @DATABASE <name>
  325.   Must be the very first line of a Amiga HyperText document.
  326.  
  327.   @MASTER <path>
  328.   Complete path of the source document used to define this HyperText
  329.   database.
  330.  
  331.   @NODE <name> <title>
  332.   Indicate the start of a node (page/article/section). The first node,
  333.   or main node, must be named MAIN.  MAIN must be the master table of
  334.   contents for the database.
  335.  
  336.   @DNODE <name>
  337.   Indicates the start of a dynamic node.  The HyperText system uses the
  338.   callback hooks to obtain the document from a document provider.
  339.  
  340.   @INDEX <name/node>
  341.   Specify the name of the index node, accessed by the Index button.  Can
  342.   be a node in an external database.
  343.  
  344.   @REMARK <remark>
  345.   Remark (not displayed to the user).
  346.  
  347.  
  348. Node Label Commands
  349.  
  350. These are commands that can be used within a @NODE.
  351.  
  352.  
  353.   @ENDNODE <name>
  354.   Indicate the end of a node.  Must start at the beginning of a line.
  355.  
  356.   @TITLE <title>
  357.   Title to display in the title bar of the window during the display of
  358.   this node.  Must start at the beginning of a line.
  359.  
  360.   @TOC <node name>
  361.   Name of the node that contains the table of contents for this node.
  362.   Defaults to MAIN.  This is the node that is displayed when the user
  363.   presses the "Contents" button.
  364.  
  365.   @PREV <node name>
  366.   Node to display when the user selects "< Browse"
  367.  
  368.   @NEXT <node name>
  369.   Node to display when the user selects "Browse >"
  370.  
  371.   @{<label> <command>}
  372.   Indicate a textual link point.  Can be anywhere in a line.
  373.  
  374.  
  375. Action Commands
  376.  
  377. These are commands that can be assigned to a link point.
  378.  
  379.  
  380.   ALINK <name> <line>
  381.   Load the named node into a new window, with <line> at the top of the
  382.   display.
  383.  
  384.   CLOSE
  385.   Close the window (should only be used on windows that where started
  386.   with alink).
  387.  
  388.   LINK <name> <line>
  389.   Load the named node, with <line> at the top of the display.
  390.  
  391.   RX <command>
  392.   Execute an ARexx macro.
  393.  
  394.   RXS <command>
  395.   Execute an ARexx string file.  To display a picture, use 'ADDRESS
  396.   COMMAND DISPLAY <picture name>', to display a text file 'ADDRESS
  397.   COMMAND MORE <doc>'.
  398.  
  399.   SYSTEM <command>
  400.   Execute an AmigaDOS command.
  401.  
  402.   QUIT
  403.   Shutdown the current database.
  404.  
  405.  
  406. Example AmigaGuide Database
  407.  
  408. The following is an example of an AmigaGuide database.  It doesn't
  409. contain any 'useful' information, but it does show the usage of some
  410. of the commands.
  411.  
  412.  
  413.     @database "example.guide"
  414.     @master "example.doc"
  415.  
  416.     @node Main "Example AmigaGuide database"
  417.  
  418.     Table of Contents
  419.  
  420.        @{"ARexx" link ARexx}
  421.        @{"Shell" link Shell}
  422.        @{"Workbench" link Workbench}
  423.  
  424.     @endnode
  425.  
  426.     @node ARexx
  427.     Put something here about ARexx
  428.     @endnode
  429.  
  430.     @node Shell
  431.     Put something here about the Shell
  432.     @endnode
  433.  
  434.     @node Workbench
  435.     Put something here about Workbench. Say that it has @{"icons" link icon}.
  436.     @endnode
  437.  
  438.     @icon "Workbench Icons"
  439.     Those little pictures that you can drag around.
  440.     @endnode
  441.  
  442.  
  443.  
  444.                             AREXX SCRIPTS
  445.  
  446.  
  447. It is possible to control AmigaGuide using ARexx.  Each occurrence of
  448. AmigaGuide has an ARexx port.  The AmigaGuide shared system library
  449. is also an ARexx function host.
  450.  
  451.  
  452. Port Naming
  453.  
  454. The default port name is AMIGAGUIDE.# where # is the occurrence. With
  455. the AmigaGuide utility, a port name can be specified as a command
  456. line argument.  An application with an AmigaGuide interface can also
  457. provide the port name.
  458.  
  459.  
  460. ARexx Commands
  461.  
  462. Any of the following action commands are also ARexx commands.  All
  463. commands are not case-sensitive.
  464.  
  465.  
  466.   ALINK <name> <line>
  467.   Load the named node into a new window, with <line> at the top of the
  468.   display.
  469.  
  470.   CLOSE
  471.   Close the window (should only be used on windows that where started
  472.   with alink).
  473.  
  474.   LINK <name> <line>
  475.   Load the named node, with <line> at the top of the display.
  476.  
  477.   SYSTEM <command>
  478.   Execute an AmigaDOS command.
  479.  
  480.   QUIT
  481.   Shutdown the current database.
  482.  
  483.  
  484. ARexx Functions
  485.  
  486. The amigaguide.library is an ARexx function library.  The library can
  487. be added as a function host with the following lines:
  488.  
  489.  
  490.   /* Load the HyperText library as a function host */
  491.   IF ~SHOW('L','amigaguide.library') THEN
  492.      CALL ADDLIB('amigaguide.library',0,-30)
  493.  
  494.  
  495. It supports the following functions (function names are not case-
  496. sensitive).
  497.  
  498.  
  499.   ShowNode
  500.   PUBSCREEN/K,DATABASE/K,NODE/K,LINE/N
  501.   Display a node on the named screen.  Defaults to the Main node, on
  502.   the Workbench screen.  If DATABASE isn't specified, then will search
  503.   through the cross-reference list to get the database name.
  504.  
  505.  
  506.   LoadXRef
  507.   NAME/K
  508.   Load a cross-reference file into memory.
  509.  
  510.  
  511.   GetXRef
  512.   NODE/K
  513.   Return information on NODE.  Format of the text string returned is
  514.   "NODE" "DATABASE" TYPE LINE.
  515.  
  516.   ExpungeXRef
  517.   ,
  518.   Flush the cross-reference list from memory.
  519.  
  520.  
  521.  
  522.          ADDING AN AmigaGuide INTERFACE TO YOUR APPLICATION
  523.  
  524.  
  525. Applications can add AmigaGuide support, using the functions within
  526. the amigaguide.library.
  527.  
  528. The HyperApp example on disk illustrates how to add context sensitive
  529. help to an application.
  530.  
  531.  
  532.  
  533.                         CROSS REFERENCE FILES
  534.  
  535.  
  536. AmigaGuide allows cross-reference tables to be loaded that specify
  537. what document a keyword is defined in.  This cross-reference table is
  538. used by the "Find Document" requester to locate a node.  It is also
  539. used by the AD2HT utility to construct hypertext versions of the
  540. system Autodoc files.
  541.  
  542. A cross-reference file follows a layout similar to the devs:mountlist
  543. format. The table itself starts with a line that consists of the
  544. keyword XREF: and ends with a line that contains a # as the only
  545. uncommented character. Comments can be included in the C-style
  546. format, beginning with "/*" and ending with "*/".
  547.  
  548.  
  549.     /* This is a comment */
  550.     XREF:
  551.     ...
  552.     "Gadget"    "intuition/intuition.h"    215 3
  553.     ...
  554.     #
  555.  
  556.  
  557. A cross-reference entry consists of four words:
  558.  
  559.  
  560.   Keyword
  561.   The keyword that is being defined.
  562.  
  563.   File
  564.   The ASCII file or database that the keyword is defined in.
  565.  
  566.   Line
  567.   The line within the node that the keyword is defined on.
  568.  
  569.   Type
  570.   This field indicates the type of keyword.  Possible values are.
  571.  
  572.     0  Generic AmigaGuide link.
  573.     1  Describes a function.
  574.     2  Describes a command.
  575.     3  Points to an include file.
  576.     4  Describes a macro.
  577.     5  Describes a structure.
  578.     6  Describes a structure field.
  579.     7  Describes a type definition.
  580.     8  Describes a define.
  581.  
  582.  
  583. Loading a Cross Reference List
  584.  
  585. A cross-reference list can be loaded from disk using the LoadXRef()
  586. function.  The format is.
  587.  
  588.  
  589.   success = LoadXRef(lock, name);
  590.  
  591.   LONG success;
  592.   BPTR lock;
  593.   STRPTR name;
  594.  
  595.  
  596. The arguments are.
  597.  
  598.  
  599.   lock
  600.   Lock on the directory where the file is located.  May be NULL.
  601.  
  602.   name
  603.   Name of the cross-reference file to load.  LoadXRef will search the
  604.   user preference path.
  605.  
  606.  
  607. Returns
  608.  
  609.  
  610.   -1  Indicates that the load was aborted by a control-C.
  611.  
  612.    0  Unable to load the file.
  613.  
  614.    1  Successfully loaded the file.
  615.  
  616.    2  No changes have been made since the last time that this file was
  617.       loaded.
  618.  
  619.  
  620. Access to the Cross Reference List
  621.  
  622. An application can use the GetAmigaGuideAttr() function to obtain a
  623. pointer to the cross-reference list.  The application then may search
  624. through the list, or even save the list to disk.  Note that access to
  625. this list is read-only, and must be enclosed between a call to
  626. LockAmigaGuideBase() and UnlockAmigaGuideBase().
  627.  
  628.  
  629.     struct List *list;
  630.     LONG key;
  631.  
  632.     /* Lock the AmigaGuideBase for exclusive access */
  633.     key = LockAmigaGuideBase(NULL);
  634.  
  635.     /* Get a pointer to the cross-reference list */
  636.     if (GetAmigaGuideAttr(AGA_XRefList, NULL, &list))
  637.     {
  638.     /* Do something with the list */
  639.     }
  640.  
  641.     /* Unlock AmigaGuideBase */
  642.     UnlockAmigaGuideBase(key);
  643.  
  644.  
  645.  
  646. The cross-reference list consist of nodes of struct XRef, defined in
  647. <libraries/amigaguide.h>.
  648.  
  649.  
  650.     /* Cross-reference node */
  651.     struct XRef
  652.     {
  653.         struct Node xr_Node;    /* Embedded node */
  654.         UWORD xr_Pad;        /* Padding */
  655.         struct DocFile *xr_DF;    /* (Private) Document defined in */
  656.         STRPTR xr_File;        /* Name of document file */
  657.         STRPTR xr_Name;        /* Name of item */
  658.         LONG xr_Line;        /* Line defined at */
  659.     };
  660.  
  661.     #define    XRSIZE    (sizeof (struct XRef))
  662.  
  663.  
  664. Following are the field definitions.
  665.  
  666.  
  667.   xr_Node
  668.   Embedded node structure.
  669.   xr_Node.ln_Name points to xr_Name.
  670.   xr_Node.ln_Type contains the type of the keyword.
  671.  
  672.   xr_Pad
  673.   Used to align the remaining fields.
  674.  
  675.   xr_DF
  676.   Private pointer.
  677.  
  678.   xr_File
  679.   Pointer to the name of the file that xr_Name is defined in.
  680.  
  681.   xr_Name
  682.   Pointer to the keyword.
  683.  
  684.   xr_Line
  685.   The line, within xr_File, that xr_Name is defined on.
  686.  
  687.  
  688.  
  689.                           DYNAMIC NODE HOST
  690.  
  691.  
  692. AmigaGuide provides a unique feature to hypertext systems, called
  693. Dynamic Nodes.  A Dynamic Node is a hypertext or plain text document
  694. that is generated in real-time as opposed to coming from a static
  695. file.  An application that generates Dynamic Nodes is called a
  696. Dynamic Node Host.
  697.  
  698. If a link point within a document isn't resolved, it will query a
  699. list of Dynamic Node Hosts to see if any one of these external
  700. applications can resolve the node.
  701.  
  702. This feature allows for dynamic interaction with constantly changing
  703. data.  This feature is useful for AmigaGuide authoring tools,
  704. interactive development environments, extremely context sensitive
  705. help systems, to name a few.
  706.  
  707. Dynamic Nodes has been implemented using an Object Oriented
  708. Programming paradigm.  When a link point hasn't been resolved a
  709. HM_FindNode message is sent to each Dynamic Node Host on the list.
  710. Once the node has been found, then a HM_OpenNode is sent to the
  711. Dynamic Node Host that the node belongs to.  HM_CloseNode is sent to
  712. the host once the node has been exited.
  713.  
  714.  
  715. Initializing a Dynamic Node Host
  716.  
  717. In order for an application to register itself as a Dynamic Node
  718. Host, it must initialize a hook and add the hook to the AmigaGuide
  719. Dynamic Node list, using the AddAmigaGuideHost() library call.
  720.  
  721. The hook structure as defined in <utility/hooks.h>.
  722.  
  723.  
  724.     /* Standard hook structure */
  725.     struct Hook
  726.     {
  727.         struct MinNode h_MinNode;
  728.         ULONG (*h_Entry)();        /* assembler entry point */
  729.         ULONG (*h_SubEntry)();        /* often HLL entry point */
  730.         VOID *h_Data;            /* owner specific */
  731.     };
  732.  
  733.  
  734. The AddAmigaGuideHost() function returns a pointer to an
  735. AmigaGuideHost structure.  This structure, defined in
  736. <libraries/amigaguide.h>, is as follows.
  737.  
  738.  
  739.     /* Callback handle */
  740.     struct AmigaGuideHost
  741.     {
  742.         struct Hook agh_Dispatcher;    /* Dispatcher */
  743.         ULONG agh_Reserved;        /* Must be 0 */
  744.         ULONG agh_Flags;
  745.         ULONG agh_UseCnt;        /* Number of open nodes */
  746.         APTR agh_SystemData;        /* Reserved for system use */
  747.         APTR agh_UserData;        /* Anything you want... */
  748.     };
  749.  
  750.  
  751. Following are the field definitions for the AmigaGuideHost structure.
  752.  
  753.  
  754.   agh_Dispatcher
  755.   This is a copy of the Hook that was passed to AddAmigaGuideHost().
  756.  
  757.   agh_UserData
  758.   Can be manipulated by the Dynamic Node Host any way it sees fit.
  759.  
  760.  
  761.   The other fields are not to be manipulated in any way.
  762.  
  763.  
  764. Removing a Dynamic Node Host
  765.  
  766. A Dynamic Node Host is removed using the RemoveAmigaGuideHost()
  767. library function.  The application must successfully remove the hook
  768. before exiting, otherwise AmigaGuide would end up calling the hook
  769. function, that has been unloaded from the system, causing a system
  770. crash.
  771.  
  772. The following code fragment illustrates how to initialize and remove
  773. a Dynamic Node Host.
  774.  
  775.  
  776.     #include <exec/types.h>
  777.     #include <libraries/amigaguide.h>
  778.     #include <clib/exec_protos.h>
  779.     #include <clib/amigaguide_protos.h>
  780.     #include <pragmas/exec_pragmas.h>
  781.     #include <pragmas/amigaguide_pragmas.h>
  782.     #include <stdio.h>
  783.  
  784.     extern struct Library *SysBase, *DOSBase;
  785.     struct Library *AmigaGuideBase;
  786.  
  787.     #define    ASM    __asm
  788.     #define    REG(x)    register __ ## x
  789.  
  790.     ULONG __saveds dispatchDNH(struct Hook *, STRPTR, Msg);
  791.     ULONG ASM hookEntry(REG(a0) struct Hook *,REG(a2) VOID *,REG(a1) VOID *);
  792.  
  793.     /* Callback hook dispatcher */
  794.     ULONG __asm hookEntry (
  795.         REG(a0) struct Hook *h,
  796.         REG(a2) VOID *obj,
  797.         REG(a1) VOID *msg)
  798.     {
  799.         /* Pass the parameters on the stack */
  800.         return ((h->h_SubEntry)(h, obj, msg));
  801.     }
  802.  
  803.     main (int argc, char **argv)
  804.     {
  805.     struct Hook hook;
  806.     AMIGAGUIDEHOST hh;
  807.  
  808.     /* amigaguide.library works with 1.3 and newer versions of the OS */
  809.     if (AmigaGuideBase = OpenLibrary ("amigaguide.library", 33))
  810.     {
  811.         /* Initialize the hook */
  812.         hook.h_Entry = hookEntry;
  813.         hook.h_SubEntry = dispatchDNH;
  814.  
  815.         /* Add the AmigaGuideHost to the system */
  816.         if (hh = AddAmigaGuideHost (&hook, "ExampleHost", NULL))
  817.         {
  818.         printf ("Added AmigaGuideHost 0x%lx\n", hh);
  819.  
  820.         /* Wait until we're told to quit */
  821.         Wait (SIGBREAKF_CTRL_C);
  822.  
  823.         printf ("Remove AmigaGuideHost 0x%lx", hh);
  824.  
  825.         /* Try removing the host */
  826.         while (RemoveAmigaGuideHost (hh, NULL) > 0)
  827.         {
  828.             /* Wait a while */
  829.             printf (".");
  830.             Delay (250);
  831.         }
  832.         printf ("\n");
  833.         }
  834.         else
  835.         {
  836.         printf ("Couldn't add AmigaGuideHost\n");
  837.         }
  838.  
  839.         /* close the library */
  840.         CloseLibrary (AmigaGuideBase);
  841.     }
  842.     }
  843.  
  844.  
  845. Handling Dynamic Node Host Messages
  846.  
  847. Once the Dynamic Node Host has been added to AmigaGuide, it can start
  848. receiving messages for different requests.
  849.  
  850. Currently, AmigaGuide supports the following methods, or message
  851. types, for a Dynamic Node Host.
  852.  
  853.  
  854.   HM_FindNode
  855.   When AmigaGuide can't resolve a link, then it sends a HM_FindNode
  856.   message to all Dynamic Node Hosts to see which host defines the
  857.   node.
  858.  
  859.   HM_OpenNode
  860.   Once AmigaGuide locates the host that defines a node, using the
  861.   HM_FindNode message, then the HM_OpenNode message is sent to that
  862.   host to ask it to open the node.
  863.  
  864.   HM_CloseNode
  865.   Once the user has closed all occurrences of a Dynamic Node, then
  866.   AmigaGuide sends the HM_CloseNode message to the host that opened
  867.   the node.
  868.  
  869.   HM_Expunge
  870.   AmigaGuide sends this message to all Dynamic Node Hosts when the
  871.   Expunge vector of amigaguide.library is invoked, or the
  872.   ExpungeDataBases() function is called.
  873.  
  874.  
  875. Several of the methods receive a TagItem array as an argument.
  876. Currently the following tags are supported.  The tag values are
  877. defined in <libraries/amigaguide.h>.
  878.  
  879.  
  880.   HTNA_Screen
  881.   A pointer to the screen on which source AmigaGuide window resides.
  882.  
  883.   HTNA_Pens
  884.   The pen array associated with the screen.
  885.  
  886.   HTNA_Rectangle
  887.   A Rectangle structure (defined in <graphics/gfx.h>) containing the
  888.   dimensions of the window.
  889.  
  890.  
  891. Each method requires one or more parameters.  The MethodID is the
  892. only common parameter for each method.
  893.  
  894.  
  895. HM_FindNode
  896.  
  897. Used to locate the Dynamic Node Host that a node is defined by.  When
  898. a Dynamic Node Host receives a HM_FindNode message for a node that it
  899. owns, it should reply with TRUE, otherwise it must respond with FALSE.
  900.  
  901. The HM_FindNode method receives the following arguments:
  902.  
  903.  
  904.     /* HM_FindNode */
  905.     struct opFindHost
  906.     {
  907.         ULONG MethodID;
  908.         struct TagItem *ofh_Attrs;    /*  R: Additional attributes */
  909.         STRPTR ofh_Node;        /*  R: Name of node */
  910.         STRPTR ofh_TOC;            /*  W: Table of Contents */
  911.         STRPTR ofh_Title;        /*  W: Title to give to the node */
  912.         STRPTR ofh_Next;        /*  W: Next node to browse to */
  913.         STRPTR ofh_Prev;        /*  W: Previous node to browse to */
  914.     };
  915.  
  916.  
  917. The field definitions are as follows
  918.  
  919.  
  920.   ofh_Attrs
  921.   This field contains a pointer to a TagItem array of attributes for
  922.   the message.  This field is read-only.
  923.  
  924.   ofh_Node
  925.   The name of the node to open.  This field is read-only.  It is
  926.   possible for this name to contain parameters that need to be
  927.   parsed.  For example, the command that triggered the link could
  928.   have been:
  929.  
  930.     Link "snd/beep 320"
  931.  
  932.   In which case, the ofh_Node field would contain:
  933.  
  934.     beep 320
  935.  
  936.   ofh_TOC
  937.   The Table of Contents to assign to this node.  This is the name of
  938.   the node to link to, if the "Contents" button is pressed.  This
  939.   field can be written to (not implemented).
  940.  
  941.   ofh_Title
  942.   The title to assigned to this node.  This field can be written to.
  943.  
  944.   ofh_Next
  945.   The name of the logical next node.  This is the name of the node to
  946.   link to if the "Browse >" button is pressed. This field can be
  947.   written to.
  948.  
  949.   ofh_Prev
  950.   The name of the logical previous node.  This is the name of the
  951.   node to link to if the "< Browse" button is pressed.   This field
  952.   can be written to.
  953.  
  954.  
  955.  
  956. HM_OpenNode
  957.  
  958. Once AmigaGuide locates the host that defines a node, using the
  959. HM_FindNode message, then the HM_OpenNode message is sent to that
  960. host to ask it to open the node. If the Dynamic Node Host is able to
  961. open the node, then it should respond with TRUE, otherwise respond
  962. with FALSE.
  963.  
  964. The HM_OpenNode method receives the following arguments:
  965.  
  966.  
  967.     /* HM_OpenNode, HM_CloseNode */
  968.     struct opNodeIO
  969.     {
  970.         ULONG MethodID;
  971.         struct TagItem *onm_Attrs;    /*  R: Additional attributes */
  972.         STRPTR onm_Node;        /*  R: Node name and arguments */
  973.         STRPTR onm_FileName;        /*  W: File name buffer */
  974.         STRPTR onm_DocBuffer;        /*  W: Node buffer */
  975.         ULONG onm_BuffLen;        /*  W: Size of buffer */
  976.         ULONG onm_Flags;        /* RW: Control flags */
  977.     };
  978.  
  979.  
  980. The field definitions are as follows
  981.  
  982.  
  983.   onm_Attrs
  984.   This field contains a pointer to a TagItem array of attributes for the
  985.   message.  This field is read-only.
  986.  
  987.   onm_Node
  988.   The name of the node to open.  This field is read-only.  It is possible
  989.   for this name to contain parameters that need to be parsed.  For
  990.   example, the command that triggered the link could have been:
  991.  
  992.     Link "snd/beep 320"
  993.  
  994.   In which case, the onm_Node field would contain:
  995.  
  996.     beep 320
  997.  
  998.   onm_FileName
  999.   If you want AmigaGuide to read a particular node from disk, then supply
  1000.   the file name here.  The file can either be a straight ASCII file or an
  1001.   AmigaGuide document (not a database).  The application can write to
  1002.   this field.
  1003.  
  1004.   onm_DocBuffer
  1005.   If you are dynamically creating a node in memory, then use this field
  1006.   to point to the buffer.  If this field is used, then the onm_BuffLen
  1007.   field must be filled in also.  The application is in charge of freeing
  1008.   onm_DocBuffer when it is done (indicated by a HM_CloseNode message).
  1009.   The application can write to this field.
  1010.  
  1011.   onm_BuffLen
  1012.   The length of the buffer that onm_DocBuffer points to.  The
  1013.   application can write to this field.
  1014.  
  1015.   onm_Flags
  1016.   These are control flags that the Dynamic Node Host can set.
  1017.  
  1018.     HTNF_KEEP - Don't flush this node from memory until the database is
  1019.     closed.  This will delay the HM_CloseNode message until the database
  1020.     is closed.
  1021.  
  1022.     HTNF_ASCII - The node is straight ASCII, doesn't contain any
  1023.     AmigaGuide keywords.
  1024.  
  1025.     HTNF_CLEAN - Remove the node from the database as soon as it is
  1026.     closed.
  1027.  
  1028.     HTNF_DONE - This flag is used to indicate to AmigaGuide that the
  1029.     Dynamic Node Host already took care of presenting the node, and
  1030.     that there is no need for AmigaGuide to present it.  This is
  1031.     useful for playing sounds, animations, or even debugging
  1032.     information.
  1033.  
  1034.  
  1035. HM_CloseNode
  1036.  
  1037. Once the user has closed all occurrences of a Dynamic Node, then
  1038. AmigaGuide sends the HM_CloseNode message to the host that opened the
  1039. node.  If the Dynamic Node Host is able to close the node, then
  1040. respond with TRUE, otherwise respond with FALSE.
  1041.  
  1042. The HM_CloseNode message uses the same message structure as HM_OpenNode.
  1043.  
  1044.  
  1045. HM_Expunge
  1046.  
  1047. AmigaGuide sends this message to all Dynamic Node Hosts when the
  1048. Expunge vector of amigaguide.library is invoked, or the
  1049. ExpungeDataBases() function is called. The Dynamic Node Host should
  1050. free as much memory as it possibly can.
  1051.  
  1052. The HM_Expunge method receives the following arguments:
  1053.  
  1054.  
  1055.     /* HM_Expunge */
  1056.     struct opExpungeNode
  1057.     {
  1058.         ULONG MethodID;
  1059.         struct TagItem *oen_Attrs;    /*  R: Additional attributes */
  1060.     };
  1061.  
  1062.  
  1063. The field definitions are as follows
  1064.  
  1065.  
  1066.   oen_Attrs
  1067.   Currently, no attributes passed.
  1068.  
  1069.  
  1070. Message Dispatcher
  1071.  
  1072. The following is an example of Dynamic Node Host message dispatcher.
  1073. Since this is executed with a callback hook, it is being run on the
  1074. calling process' task, not the Dynamic Node Host process.  Because of
  1075. that, it is necessary to load the global data segment using geta4()
  1076. or __saveds.
  1077.  
  1078.  
  1079.     ULONG __saveds
  1080.     dispatchAmigaGuideHost (struct Hook *h, STRPTR db, Msg msg)
  1081.     {
  1082.         struct opNodeIO *onm = (struct opNodeIO *) msg;
  1083.         ULONG retval = 0;
  1084.  
  1085.         switch (msg->MethodID)
  1086.         {
  1087.             /* Does this node belong to you? */
  1088.             case HM_FindNode:
  1089.                 {
  1090.                     struct opFindHost *ofh = (struct opFindHost *) msg;
  1091.  
  1092.                     DB (kprintf ("Find [%s] in %s\n", ofh->ofh_Node, db));
  1093.  
  1094.                     /* See if they want to find our table of contents */
  1095.                     if ((stricmp (ofh->ofh_Node, "main")) == 0)
  1096.                     {
  1097.                         /* Return TRUE to indicate that it's your node,
  1098.                          * otherwise return FALSE. */
  1099.                         retval = TRUE;
  1100.                     }
  1101.                     else
  1102.                     {
  1103.                         /* Display the name of the node */
  1104.                         Display (onm);
  1105.  
  1106.                         /* Return TRUE to indicate that it's your node,
  1107.                          * otherwise return FALSE. */
  1108.                         retval = FALSE;
  1109.                     }
  1110.                 }
  1111.                 break;
  1112.  
  1113.             /* Open a node. */
  1114.             case HM_OpenNode:
  1115.                 DB (kprintf ("Open [%s] in %s\n", onm->onm_Node, db));
  1116.  
  1117.                 /* See if they want to display our table of contents */
  1118.                 if ((stricmp (onm->onm_Node, "main")) == 0)
  1119.                 {
  1120.                     /* Provide the contents of the node */
  1121.                     onm->onm_DocBuffer = TEMP_NODE;
  1122.                     onm->onm_BuffLen = strlen (TEMP_NODE);
  1123.                 }
  1124.                 else
  1125.                 {
  1126.                     /* Display the name of the node */
  1127.                     Display (onm);
  1128.  
  1129.                     /* Indicate that we want the node removed from our
  1130.                      * database, and that we handled the display of the
  1131.              * node */
  1132.                     onm->onm_Flags |= (HTNF_CLEAN | HTNF_DONE);
  1133.                 }
  1134.  
  1135.                 /* Indicate that we were able to open the node */
  1136.                 retval = TRUE;
  1137.                 break;
  1138.  
  1139.             /* Close a node that has no users. */
  1140.             case HM_CloseNode:
  1141.                 DB (kprintf ("Close [%s] in %s\n", onm->onm_Node, db));
  1142.  
  1143.                 /* Indicate that we were able to close the node */
  1144.                 retval = TRUE;
  1145.                 break;
  1146.  
  1147.             /* Free any extra memory */
  1148.             case HM_Expunge:
  1149.                 DB (kprintf ("Expunge [%s]\n", db));
  1150.                 break;
  1151.  
  1152.             default:
  1153.                 DB (kprintf ("Unknown method %ld\n", msg->MethodID));
  1154.                 break;
  1155.         }
  1156.  
  1157.         return (retval);
  1158.     }
  1159.  
  1160.  
  1161.  
  1162.                     DEVELOPER SPECIFIC UTILITIES
  1163.  
  1164.  
  1165. On the DevCon disks are a number of utilities for AmigaGuide that
  1166. would be of special interest to the developer.
  1167.  
  1168.  
  1169.   AD2HT
  1170.   Scans Autodocs for function and command names, scans the INCLUDE:
  1171.   directory for .h include files, and scans the include files for
  1172.   structure definitions.  Also parses Autodoc files and constructs a
  1173.   corresponding AmigaGuide database.  It resolves links to functions,
  1174.   commands, include files and structures.
  1175.  
  1176.   CXRef
  1177.   Scans a source directory and builds a cross-reference showing where
  1178.   all functions and structures are defined.  Something like ctags on
  1179.   the Sun.
  1180.  
  1181.  
  1182.  
  1183.                               GLOSSARY
  1184.  
  1185.  
  1186. Autodoc
  1187.   Documentation extracted from source code.
  1188.  
  1189. browse
  1190.   Navigate sequentially through a series of documents, instead of via
  1191.   links.
  1192.  
  1193. cross-reference table
  1194.   A table that consists of the following information:
  1195.  
  1196.   keyword
  1197.   A word or phrase
  1198.  
  1199.   database
  1200.   Name of the database that the keyword is defined in.
  1201.  
  1202.   line
  1203.   The line that the keyword is defined on within the database.  This only
  1204.   applies if the database is a straight text file (such as an include
  1205.   file).
  1206.  
  1207.   type
  1208.   What type the keyword is, such as a 'normal', function, command,
  1209.   include file, or structure.
  1210.  
  1211. database
  1212.   A file that consists of multiple documents.
  1213.  
  1214. document
  1215.   A block of text, constrained to one subject.  Also called a node.
  1216.  
  1217. Dynamic Node
  1218.   A Dynamic Node is a hypertext, or plain text, document that is
  1219.   generated in real-time, or from live data, as opposed to coming from a
  1220.   static file.
  1221.  
  1222. Dynamic Node Host
  1223.   An application that generates Dynamic Nodes.
  1224.  
  1225. link
  1226.   A word, or phrase, within a document that is linked to another
  1227.   document.
  1228.  
  1229. node
  1230.   A block of text, constrained to one subject.  Also called a document.
  1231.  
  1232. retrace
  1233.   To follow, in a reverse direction, the path taken through a series of
  1234.   documents.
  1235.  
  1236. table of contents
  1237.   A list of documents, categorized by type.
  1238.  
  1239.  
  1240.  
  1241.                          RECOMMENDED READING
  1242.  
  1243.  
  1244. "Hypertext Hands-On!" Ben Shneiderman & Greg Kearsley. Addison-Wesley
  1245. Publishing Company. ISBN 0-201-13546-9
  1246.  
  1247. "Understanding Hypertext Concepts and Applications" Philip Seyer.
  1248. Windcrest Books. ISBN 0-8306-9108-1 (hard)  0-8306-3308-1 (pbk.)
  1249.